﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using LinFu.IoC.Configuration;
using LinFu.IoC.Interfaces;
using LinFu.IoC;
namespace CoreEx.Database.Client.Implementation
{
    [Factory(typeof(DbProviderFactory))]
    public class DbProviderFactoryFactory : IFactory<DbProviderFactory>
    {        
        public DbProviderFactory CreateInstance(IFactoryRequest request)
        {
            var connectionInfo = request.Container.GetService<IConnectionInfo>(request.ServiceName);                        
            var proxyFactory = request.Container.GetService<IProxyFactory<DbProviderFactory>>();

            return proxyFactory.CreateProxy(DbProviderFactories.GetFactory(connectionInfo.ProviderName));
                        
        }
    }
}
